package com.tvein.sanguo.controller.Game
{
	//flash
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.view.ApplicationMediator;
	
	import com.tvein.sanguo.controller.Game.user.GameStart;
	import com.tvein.sanguo.controller.Game.user.GameMessage;
	import com.tvein.sanguo.controller.Game.user.GameCommand;
	
	import com.tvein.sanguo.controller.Game.user.UserLogin;
	import com.tvein.sanguo.controller.Game.user.UserCreate;
	import com.tvein.sanguo.controller.Game.user.UserConfirm;

	import com.tvein.sanguo.controller.Game.user.RoleList;
	import com.tvein.sanguo.controller.Game.user.RoleCreate;
	import com.tvein.sanguo.controller.Game.user.RoleDelete;
	
	import com.tvein.sanguo.controller.Game.user.RoleLogin;
	import com.tvein.sanguo.controller.Game.user.RoomChange;
	import com.tvein.sanguo.controller.Game.user.RoleRoomPass;
//
	public class GameConsole extends SimpleFabricationCommand implements ICommand
	{
		private var sanguoMediator:ApplicationMediator;
		
		override public function execute(notification:INotification) : void
		{
			sanguoMediator = facade.retrieveMediator(ApplicationMediator.NAME) as ApplicationMediator;
			
			sanguoMediator.sysLog.appendText(notification.getBody() + "\n");
			
			var commandInstance:ICommand;
			
			switch(notification.getBody()[0])
			{
				case "-gameStart":
					commandInstance = new GameStart();
					break;
				case "-gameMessage":
					commandInstance = new GameMessage();
					break;
				case "-gameCommand":
					commandInstance = new GameCommand();
					break;
				//
				case "-userLogin":
					commandInstance = new UserLogin();
					break;
				case "-userCreate":
					commandInstance = new UserCreate();
					break;
				case "-userConfirm":
					commandInstance = new UserConfirm();
					break;
				//sfs user cmd
				case "-roleList":
					commandInstance = new RoleList();
					break;
				case "-roleCreate":
					commandInstance = new RoleCreate();
					break;
				case "-roleDelete":
					commandInstance = new RoleDelete();
					break;
				case "-roleLogin":
					commandInstance = new RoleLogin();
					break;
				case "-roomChange":
					commandInstance = new RoomChange();
					break;
				//sfs server cmd
				case "-roleRoomPass":
					commandInstance = new RoleRoomPass();
					break;
			}
			
			commandInstance.initializeNotifier(multitonKey);
			commandInstance.execute(notification);
		}
	}
}